package org.streets.wicket;

import org.apache.wicket.protocol.http.ContextParamWebApplicationFactory;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WicketFilter;

/**
 *
 * @author dzb
 */
public class HiveWebApplicationFactory extends ContextParamWebApplicationFactory {
	
	@Override
    public WebApplication createApplication(WicketFilter filter) {
    	
        HiveWicketSettings settings = (HiveWicketSettings) filter;        
        String applicationClassName = settings.applicationClass();
        
        if (applicationClassName == null) {
        	applicationClassName = settings.applicationName();
        	if (!applicationClassName.endsWith("Application")) {
        		applicationClassName = applicationClassName + "Application";
        	}
        	applicationClassName = (settings.moduleBasePackage() == null ? "" : settings.moduleBasePackage()) + applicationClassName; 
        }
        return super.createApplication(applicationClassName);
    }
}
